<cfif IsDefined('Attributes.day_id') >
	<cfquery name="list" datasource="#Request.DS#" result="result">
		DELETE FROM `cfp_weeks` WHERE
			`id` = (SELECT `week_id` FROM `cfp_days`
				WHERE `id` = '#Attributes.day_id#' AND `user_id` = '#Session.id#') AND
			`text` = '' AND
			(SELECT count(`id`) as `counted` FROM `cfp_entries`
				WHERE `day_id` = '#Attributes.day_id#' AND `user_id` = '#Session.id#' ) = 1 AND `user_id` = '#Session.id#'
	</cfquery>
	<cfquery datasource="#Request.DS#">
		DELETE FROM `cfp_days` WHERE
			`id` = '#Attributes.day_id#' AND
			(SELECT count(`id`) as `counted` FROM `cfp_entries`
				WHERE `day_id` = '#Attributes.day_id#' AND `user_id` = '#Session.id#' ) = 1 AND `user_id` = '#Session.id#'
	</cfquery>
</cfif>